﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Security;

namespace Interfaces.CronogramaDeActividades
{
    public partial class CrearCronograma : System.Web.UI.Page
    {
        string CI,res;
        int Gestion;
        System.Data.DataTable dt = new System.Data.DataTable();
        protected void Page_Load(object sender, EventArgs e)
        {
           /* if (ViewState["Ci"] != null && ViewState["Gestion"] != null)
            {
                CI=ViewState["Ci"].ToString() ;
                Gestion=Convert.ToInt32( ViewState["Gestion"].ToString());
            }*/
            if (!User.Identity.IsAuthenticated)
                FormsAuthentication.RedirectToLoginPage();
           try
                {
                    CI = Convert.ToString(DataBase.Miembro2.BDMiembro.DevolverMiembroPorUsuario(User.Identity.Name).CI);// "121212";
                    DateTime a = DateTime.Now;                    
                    Gestion =(int)a.Year;
                    ViewState["Ci"] = CI;
                    ViewState["Gestion"] = Gestion;
                    DataSet lista = Processes.CronogramaDeActividades.GestorCronogramaActividades.ObtenerListaActividades(CI, Gestion);
                    GridView1.DataSource = lista;
                    GridView1.DataBind();
                    /*  if (GridView1.Rows.Count == 0)
                          Label1.Text = "Usted no tiene actividades en esta gestion.";
                      else
                          Label1.Text = "";*/
                }
                catch (Exception expetion)
                {
                    throw expetion;
                }                   
           
        }
      
        protected void Button3_Click(object sender, EventArgs e)
        {
          //  ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "jajajaja"+ "');", true);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("CrearActividad.aspx?Ci="+CI);
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("AñadirActividadExistente.aspx?Ci=" + CI);
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["BuscarMaster"] != null)
            {
                res = (string)Session["BuscarMaster"];
                this.MasterPageFile = res;
            }
        }

    }
}